<script>
$("#control").addClass('current');
</script>
<?
$institucion = array(1=>'Metro de Caracas', 2=>'MINERVEN', 3=>'La Ovallera');
$resultados = array(1=>'metro', 2=>'minerven', 3=>'ovallera');
//pr($datos);
?>
<div class="datos">
	<h2><?php __('Listado de Cuestionarios');?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('id');?></th>
			<th><?php echo $this->Paginator->sort('Cuestionario', 'instituto');?></th>
			<th><?php echo $this->Paginator->sort('Usuario', 'usuario');?></th>
			<th><?php echo $this->Paginator->sort('Fecha de registro', 'created');?></th>
			<th><?php echo $this->Paginator->sort('Trayecto', 'trayecto');?></th>
			<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($datos as $dato):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo mascara($dato['Dato']['id']); ?>&nbsp;</td>
		<td>
			<? echo $institucion[$dato['Dato']['instituto']] ?>
		</td>
		<td><?php echo $dato['Usuario']['usuario']; ?>&nbsp;</td>
		<td><?php echo turnFecha($dato['Dato']['created']); ?>&nbsp;</td>
		<td>
			<?php
				if($dato['Dato']['trayecto'] == 777){
					echo "Finalizado";
				}else{
					if($dato['Dato']['trayecto'] == 0){
						echo $this->Html->link("FPS (continuar)", array('action' => strtolower("fps"), $dato['Dato']['instituto'], $dato['Dato']['id'], 3));
					}else{
						echo $this->Html->link($dato['Cuestionario']['name']." (continuar)", array('action' => strtolower($dato['Cuestionario']['name']), $dato['Dato']['instituto'], $dato['Dato']['id'], $dato['Dato']['trayecto']));
					}
					
				}
			?>
			
		</td>
		<td class="actions">
			
			<?php 
				if($dato['Dato']['trayecto'] == 777){
					echo $this->Html->link($html->image("material_info.png", array("width"=>"24", 'title'=>'Ver Resultados')), array('action' => 'resultados_'.$resultados[$dato['Dato']['instituto']], $dato['Dato']['id']), array('escape'=>false));
					echo $this->Html->link($html->image("material_edit.png", array("width"=>"24", 'title'=>'Editar Cuestinario')), array('action' => 'editar_'.$resultados[$dato['Dato']['instituto']], $dato['Dato']['id']), array('escape'=>false));
				}else{
					echo "<a>".$html->image("info_disabled.png", array("width"=>"24", 'title'=>'Resultados'))."</a>";
					echo "<a>".$html->image("editar_disabled.png", array("width"=>"24", 'title'=>'Editar'))."</a>";
				}
			?>
			<?php
				echo $this->Html->link($html->image("material_delete.png", array("width"=>"24", 'title'=>'Eliminar cuestionario')), array('action' => 'delete', $dato['Dato']['id']), array('escape'=>false), sprintf(__('Are you sure you want to delete # %s?', true), $dato['Dato']['id']));
				
			?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Pagina %page% de %pages%, mostrando %current% registros de %count% en total, comenzando en el registro %start%, y terminando en el %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>